<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/font-awesome.css" rel="stylesheet">
    <link href="/css/datatables.min.css" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
    <script src="/js/jquery-3.1.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/vue.js"></script>
</head>
<body style="background-color:whitesmoke">
<div id="hiring">
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>招聘记录表</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="../../../templates/index.html">主页</a>
                </li>
                <li>
                    <a>表格</a>
                </li>
                <li class="active">
                    <strong>招聘人员表格</strong>
                </li>
            </ol>
        </div>
    </div>

    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="ibox-content m-b-sm border-bottom">
            <div class="row">
                <form role="form" class="form-horizontal">
                    <div class="form-group">

                        <label class=" col-sm-2 control-label">编号</label>
                        <div class=" col-sm-2">
                            <input type="text" class="form-control" v-model="hiringQuery.id" placeholder="请输入编号">
                        </div>

                        <label class=" col-sm-2 control-label">招聘状态</label>
                        <div class=" col-sm-2">
                            <input type="text" class="form-control" v-model="hiringQuery.recruitmentState" placeholder="请输入招聘状态">
                        </div>

                        <div>
                            <button class="btn btn-primary btn-sm" type="button" @click="loadData()"><span
                                    class="glyphicon glyphicon-zoom-in"></span>查询
                            </button>
                            <button class="btn btn-primary btn-sm" type="button" @click="add()"><span
                                    class="glyphicon glyphicon-plus"></span> 新增
                            </button>
                        </div>
                    </div>
                </form>

            </div>

        </div>
        <div class="row">
            <div class="col-lg-12">

                <div class="ibox float-e-margins">

                    <div class="ibox-content">

                        <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="15">
                            <thead>
                            <tr>

                                <th data-toggle="true">编号</th>
                                <th data-toggle="true">姓名</th>
                                <th data-toggle="true">招聘内容编号</th>
                                <th data-hide="phone">招聘状态</th>
                                <!--<th data-hide="all">员工编号</th>-->
                                <th data-hide="phone">学历</th>
                                <th data-hide="phone,tablet">部门</th>
                                <th data-hide="phone,tablet">职务</th>
                                <th data-hide="phone,tablet">入职时间</th>
                                <th data-hide="phone,tablet">人员状态</th>


                                <th class="text-right" data-sort-ignore="true">信息管理操作</th>

                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="x in list">
                                <td>{{x.id}}</td>
                                <td>{{x.hrName}}</td>
                                <td>{{x.applyContent}}</td>
                                <td>{{x.recruitmentState}}</td>
                                <!--<td>{{x.empNum}}</td>-->
                                <td>{{x.formalSchool}}</td>
                                <td>{{x.department}}</td>
                                <td>{{x.position}}</td>
                                <td>{{x.workTime}}</td>
                                <td>{{x.state}}</td>


                                <td class="text-right">
                                    <button class="btn-primary btn btn-sm" @click="xiangqing(x)"><span
                                            class="glyphicon glyphicon-tag"></span> 详情
                                    </button>

                                    <button class="btn-primary btn btn-sm" @click="update(x)"><span
                                            class="glyphicon glyphicon-tag"></span> 修改
                                    </button>
                                    <button class="btn-primary btn btn-sm" @click="del(x)"><span
                                            class="glyphicon glyphicon-trash"></span> 删除
                                    </button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <div>
                            一共{{total}}条数据,一共{{totalPage}}页,当前第{{curPage}}页
                            <button class="btn btn-success btn-sm" type="button" @click="prePages()">上一页</button>
                            <button class="btn btn-success btn-sm" type="button" @click="nextPages()">下一页</button>
                            <button class="btn btn-success btn-sm" type="button" @click="indexPage()">首页</button>
                            <button class="btn btn-success btn-sm" type="button" @click="endPage()">尾页</button>
                            跳转到<input type="number" id="num" style="width: 40px" min="1" max="10" v-model="selectPage"
                                      @keyup="valNum">页
                            <button class="btn btn-success btn-sm" type="button" @click="changePage()">跳转</button>
                            <select v-model="hiringQuery.row" @change="selectRow">hiring
                                <option value="3">每页3条</option>
                                <option value="5">每页5条</option>
                                <option value="10">每页10条</option>
                            </select>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 模态框开始 -->
    <div id="one" class="modal fade" style="top:50px">
        <div class="modal-dialog">

            <div class="modal-content">
                <!--头部-->
                <div class="modal-header">
                    <h4 align="center">{{title}}</h4>

                </div>
                <!--主题内容-->
                <div class="modal-body">
                    <form role="form" class="form-horizontal">

                        <!--<div class="form-group">
                            <label class=" col-sm-2 control-label">编号</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control" v-model="hiringrecord.id" placeholder="编号可以不用填写，自动生成">
                            </div>
                        </div>-->

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">姓名</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control required" v-model="hiringrecord.hrName" placeholder="请输入姓名">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">招聘内容编号</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control required" v-model="hiringrecord.applyContent" placeholder="请输入招聘内容编号（应聘记录表ID）">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class=" col-sm-2 control-label">招聘状态</label>
                            <div class=" col-sm-10">
                            <!--<div class=" col-sm-10">
                                <input type="text" class="form-control" v-model="hiringrecord.recruitmentState" placeholder="请输入招聘状态">
                            </div>-->
                            <select v-model="hiringrecord.recruitmentState" class="form-control">
                                <option value="未处理">未处理</option>
                                <option value="笔试过">笔试过</option>
                                <option value="面试过">面试过</option>
                                <option value="签约完成">签约完成</option>
                            </select>
                            </div>
                        </div>

                        <!--<div class="form-group">
                            <label class=" col-sm-2 control-label">员工编号</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control" v-model="hiringrecord.empNum" placeholder="请输入员工编号">
                            </div>
                        </div>-->



                        <div class="form-group">
                            <label class=" col-sm-2 control-label">学历</label>
                            <div class=" col-sm-10">
                                <!--<input type="text" class="form-control required" v-model="hiringrecord.formalSchool" placeholder="请输入员工学历">-->
                                <select v-model="hiringrecord.formalSchool" class="form-control">
                                    <option value="博士">博士</option>
                                    <option value="硕士">硕士</option>
                                    <option value="本科">本科</option>
                                    <option value="专科">专科</option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class=" col-sm-2 control-label">部门</label>
                            <div class=" col-sm-10">
                            <!--<div class=" col-sm-10">
                                <input type="text" class="form-control" v-model="hiringrecord.department" placeholder="请输入部门" >
                            </div>-->
                            <!--#########################################循环获取的写法############################################-->
                            <select class="form-control" v-model="hiringrecord.department" size="">
                                <option v-for="y in sysDepts" :value="y.deptName" selected>{{y.deptName}}</option>
                            </select>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class=" col-sm-2 control-label">职务</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control" v-model="hiringrecord.position" placeholder="请输入职务">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class=" col-sm-2 control-label">入职时间</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control required" v-model="hiringrecord.workTime" placeholder="必填,格式xxxx-xx-xx" >
                            </div>
                        </div>

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">人员状态</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control required" v-model="hiringrecord.state" placeholder="请输入人员状态" >
                            </div>
                        </div>

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">笔试成绩</label>
                            <div class=" col-sm-10">
                                <input type="text" class="form-control" v-model="hiringrecord.writtenTest" placeholder="请输入笔试成绩">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class=" col-sm-2 control-label">面试成绩</label>
                            <div class=" col-sm-10">
                                <input  type="text" class="form-control" v-model="hiringrecord.interview" placeholder="请输入面试成绩">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">评价</label>
                            <div class=" col-sm-10">
                            <!--<div class=" col-sm-10">
                                <input type="text" class="form-control required" v-model="hiringrecord.evaluation" placeholder="请输入评价">
                            </div>-->
                            <select v-model="hiringrecord.evaluation" class="form-control">
                                <option value="一般">一般</option>
                                <option value="良好">良好</option>
                                <option value="优秀">优秀</option>
                                <option value="完美">完美</option>
                            </select>
                            </div>
                        </div>

                    </form>
                </div>

                <!--底部-->
                <div class="modal-footer">
                    <button class="btn btn-primary btn-sm" type="button" @click="closeWin()"><span
                            class="glyphicon glyphicon-remove"></span>关闭
                    </button>
                    <button class="btn btn-primary btn-sm" @click="saveApply()"><span
                            class="glyphicon glyphicon-save"></span>保存
                    </button>
                </div>

            </div>
        </div>
    </div>


    <!-- 模态框开始 -->
    <div id="two" class="modal fade" style="top:150px">
        <div class="modal-dialog">

            <div class="modal-content">
                <!--头部-->
                <div class="modal-header">
                    <h4 align="center">{{title}}</h4>

                </div>
                <!--主题内容-->
                <div class="modal-body">
                    <form role="form" class="form-horizontal">

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">笔试成绩</label>
                            <div class=" col-sm-10">
                                <input readonly="readonly" type="text" class="form-control" v-model="hiringrecord.writtenTest" >
                            </div>
                        </div>

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">面试成绩</label>
                            <div class=" col-sm-10">
                                <input  readonly="readonly" type="text" class="form-control" v-model="hiringrecord.interview" >
                            </div>
                        </div>

                        <div class="form-group">
                            <label class=" col-sm-2 control-label">评价</label>
                            <div class=" col-sm-10">
                                <input readonly="readonly"  type="text" class="form-control required" v-model="hiringrecord.evaluation" >
                            </div>
                        </div>

                    </form>
                </div>

                <!--底部-->
                <div class="modal-footer">
                    <button class="btn btn-primary btn-sm" type="button" @click="closeother()"><span
                            class="glyphicon glyphicon-remove"></span>关闭
                    </button>

                </div>

            </div>
        </div>
    </div>
</div>
</body>

<script>
    new Vue({
        el: "#hiring",
        data: {
            list: [],
            sysDepts:[],
            total: 0,//总条数
            totalPage: 0,//总页数
            selectPage: 1,//选择页数
            hiringQuery: { //查询对象
                page: 1,
                row: 3,
                id: null,
                recruitmentState: '',
            },
            prePage: 0,//上一页
            nextPage: 0,//下一页.
            curPage: 0,//当前页
            hiringrecord: {
                id: 0,
                hrName:"",
                applyContent:"",
                recruitmentState:"",
                empNum: "",
                formalSchool: "",
                department: "",
                position: "",
                workTime: "",
                state:"",
                writtenTest:"",
                interview:"",
                evaluation:"",
            },

            title: "信息修改"


        },
        methods: {
            loadData: function () {
                var self = this;
                $.ajax({
                    url: "/hiringrecord/hiringList",//请求地址
                    type: "get",
                    data: self.hiringQuery,
                    dataType: "json",//返回的数据类型
                    //这里的function (data)  data是后端map传过来的数据。
                    success: function (data) {
                        console.log(data);
                        self.list = data.list;
                        self.sysDepts = data.sysDepts;
                        self.total = data.total;
                        self.totalPage = data.totalPage;
                        self.prePage = data.prePage;
                        self.nextPage = data.nextPage;
                        self.curPage = data.curPage;
                    }

                })
            },
            prePages: function () {//上一页
                this.hiringQuery.page = this.prePage;
                //刷新
                this.loadData();

            },
            nextPages: function () {//下一页
                this.hiringQuery.page = this.nextPage;
                //刷新
                this.loadData();

            },
            indexPage: function () {//首页
                this.hiringQuery.page = 1
                //刷新
                this.loadData();

            },
            endPage: function () {//尾页
                this.hiringQuery.page = this.totalPage;
                //刷新
                this.loadData();

            },
            changePage: function () {//跳转
                if (this.selectPage > this.totalPage) {
                    this.hiringQuery.page = this.totalPage;
                } else {
                    this.hiringQuery.page = this.selectPage;
                }
                //刷新
                this.loadData();

            },
            selectRow: function () {//选择条数
                this.hiringQuery.page = 1
                //刷新
                this.loadData();

            },
            valNum: function () {
                //定义正则表达式对象
                var dd = /^[\u4e00-\u9fa5]{0,}$/
                //如果输入的汉字，就显示1
                if (dd.test(this.selectPage)) {
                    this.selectPage = 1
                } else {
                    console.log("==" + this.selectPage)
                    //如果输入的值大于总页数，就回到最大值
                    if (this.selectPage > this.totalPage) {
                        this.selectPage = this.totalPage;
                    }
                }


            },

            xiangqing:function(x){
                $("#two").modal("show");
                this.hiringrecord = x;
            },
            closeother: function () {
                $("#two").modal("hide");
            },

            update: function (x) {//打开修改模态框
                $("#one").modal("show")
                //数据回显
                this.hiringrecord = x;
                this.title = "信息修改";

            },
            add: function () {//打开新增模态框
                $("#one").modal("show")
                this.title = "信息新增";
                //清空
                //this.hiringrecord.id= null;
                this.hiringrecord.hrName= "";
                this.hiringrecord.recruitmentState= "";
                this.hiringrecord.empNum="";
                this.hiringrecord.formalSchool= "";
                this.hiringrecord.department="";
                this.hiringrecord.position="";
                this.hiringrecord.workTime="";
                this.hiringrecord.state="";
                this.hiringrecord.writtenTest="";
                this.hiringrecord.interview="";
                this.hiringrecord.evaluate="";

            },
            saveApply: function (x) {//保存
                var url = "";
                if (this.title == "信息修改") {
                    url = "/hiringrecord/update";
                } else {
                    url = "/hiringrecord/add";
                }
                var self = this;
                console.log(url);
                $.ajax({
                    url: url,
                    type: "post",
                    contentType: "application/x-www-form-urlencoded",
                    data: self.hiringrecord,
                    dataType: "json",
                    success: function (data) {
                        console.log(data);
                        alert(data.info);
                        if (data.info == "保存成功") {
                            //关闭模态框
                            $("#one").modal("hide")
                            //刷新
                            self.loadData();
                        }
                    }


                })

            },

            del:function(x){
                var self = this;
                var content = confirm("你确定要删除？");
                if (content){
                    $.ajax({
                        url:"/hiringrecord/del",
                        type:"post",
                        contentType:"application/x-www-form-urlencoded",
                        data:{id:x.id},
                        dataType:"json",
                        success:function (data) {
                            console.log(data);
                            alert(data.info);
                            if(data.info=="保存成功"){
                                //刷新
                                self.loadData();
                            }
                        }
                    })
                }
            },
            closeWin: function () {//关闭模态框
                $("#one").modal("hide")
                //刷新
                this.loadData();
            }

        },
        mounted() {
            //运行loadData函数
            this.loadData();
        }
    })

</script>
</html>
